package org.joy.db2;

import com.sleepycat.bind.tuple.DoubleBinding;
import com.sleepycat.bind.tuple.IntegerBinding;
import com.sleepycat.db.DatabaseEntry;

public class TfIdfEntry extends Entry {
    private int termID;
    private double tfIdf;

    public TfIdfEntry() {
    }

    public TfIdfEntry(int termID, double tfIdf) {
	super();
	this.termID = termID;
	this.tfIdf = tfIdf;
    }

    public int getTermID() {
	return termID;
    }

    public double getTfIdf() {
	return tfIdf;
    }

    @Override
    public DatabaseEntry getKeyEntry() {
	DatabaseEntry keyE = new DatabaseEntry();
	IntegerBinding.intToEntry(termID, keyE);
	return keyE;
    }

    @Override
    public DatabaseEntry getValEntry() {
	DatabaseEntry valE = new DatabaseEntry();
	DoubleBinding.doubleToEntry(tfIdf, valE);
	return valE;
    }

    @Override
    public void read(DatabaseEntry key, DatabaseEntry val) {
	this.termID = IntegerBinding.entryToInt(key);
	this.tfIdf = DoubleBinding.entryToDouble(val);
    }

}
